import request from './request';

/**
 * 学生登录
 * @param username
 * @param password
 * @returns {Promise<unknown>}
 * @constructor
 */
export const UserLogin = ({username, password}) => request('/user/loginUser', {username, password}, 'POST');

/**
 * 解析token
 * @returns {Promise<unknown>}
 * @constructor
 */
export const UseToken = ({}) => request('/user/analysisToken', {});

/**
 * 通过用户id查找某一用户还未提交的答题卡的考试
 * @param current
 * @param size
 * @param userId
 * @returns {Promise<unknown>}
 * @constructor
 */
export const EnterAbleExam = ({current, size, id}) => request("/exampage/userpage", {current, size, id});

/**
 * 通过id获取试卷
 * @param id
 * @returns {Promise<unknown>}
 * @constructor
 */
export const GetExampageById = ({id}) => request('/exampage', {id});

/**
 * 考试未结束,若用户交卷,调此方法
 * @param saveAnswer
 * @returns {Promise<unknown>}
 * @constructor
 */
export const SaveAnswer = ({AnswerContext}) => request("/answer/saveAnswer", AnswerContext, "POST");

/**
 * 通过班级id获取班级名和院系名
 * @param clazzId
 * @returns {Promise<unknown>}
 * @constructor
 */
export const GetClazz = ({clazzId}) => request("/clazz/clazz", {clazzId});

/**
 * 通过试卷id和考生id获取答题卡
 * @param examId
 * @param userId
 * @returns {Promise<unknown>}
 * @constructor
 */
export const GetAreTheExam = ({examId, userId}) => request("/answer/getAreTheExam", {examId, userId});

/**
 * 获取答题卡
 * @param answerId
 * @returns {Promise<unknown>}
 * @constructor
 */
export const GetAnswer = ({answerId}) => request("/answer/answer", {answerId});

/**
 * 提交答题卡
 * @param obj
 * @returns {Promise<unknown>}
 * @constructor
 */
// export const SubmitAnswer = ({obj}) => request("/answer/submitAnswer", obj, "POST");
export const SubmitAnswer = ({AnswerContext}) => request("/answer/submitAnswer", AnswerContext, "POST");
